﻿using System;
using System.Collections.Generic;
using System.Threading;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x020000E8 RID: 232
	internal sealed class WindowsRuntimeProjections
	{
		// Token: 0x170002B3 RID: 691
		// (get) Token: 0x0600093B RID: 2363 RVA: 0x00027C8C File Offset: 0x00025E8C
		private static Dictionary<string, WindowsRuntimeProjections.ProjectionInfo> Projections
		{
			get
			{
				bool flag = WindowsRuntimeProjections.projections != null;
				Dictionary<string, WindowsRuntimeProjections.ProjectionInfo> result;
				if (flag)
				{
					result = WindowsRuntimeProjections.projections;
				}
				else
				{
					Dictionary<string, WindowsRuntimeProjections.ProjectionInfo> value = new Dictionary<string, WindowsRuntimeProjections.ProjectionInfo>
					{
						{
							"AttributeTargets",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Metadata", "System", "AttributeTargets", "System.Runtime", false)
						},
						{
							"AttributeUsageAttribute",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Metadata", "System", "AttributeUsageAttribute", "System.Runtime", true)
						},
						{
							"Color",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI", "Windows.UI", "Color", "System.Runtime.WindowsRuntime", false)
						},
						{
							"CornerRadius",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "CornerRadius", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"DateTime",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "DateTimeOffset", "System.Runtime", false)
						},
						{
							"Duration",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "Duration", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"DurationType",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "DurationType", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"EventHandler`1",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "EventHandler`1", "System.Runtime", false)
						},
						{
							"EventRegistrationToken",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System.Runtime.InteropServices.WindowsRuntime", "EventRegistrationToken", "System.Runtime.InteropServices.WindowsRuntime", false)
						},
						{
							"GeneratorPosition",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Controls.Primitives", "Windows.UI.Xaml.Controls.Primitives", "GeneratorPosition", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"GridLength",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "GridLength", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"GridUnitType",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "GridUnitType", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"HResult",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "Exception", "System.Runtime", false)
						},
						{
							"IBindableIterable",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections", "IEnumerable", "System.Runtime", false)
						},
						{
							"IBindableVector",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections", "IList", "System.Runtime", false)
						},
						{
							"IClosable",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "IDisposable", "System.Runtime", false)
						},
						{
							"ICommand",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Input", "System.Windows.Input", "ICommand", "System.ObjectModel", false)
						},
						{
							"IIterable`1",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "IEnumerable`1", "System.Runtime", false)
						},
						{
							"IKeyValuePair`2",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "KeyValuePair`2", "System.Runtime", false)
						},
						{
							"IMapView`2",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "IReadOnlyDictionary`2", "System.Runtime", false)
						},
						{
							"IMap`2",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "IDictionary`2", "System.Runtime", false)
						},
						{
							"INotifyCollectionChanged",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "INotifyCollectionChanged", "System.ObjectModel", false)
						},
						{
							"INotifyPropertyChanged",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Data", "System.ComponentModel", "INotifyPropertyChanged", "System.ObjectModel", false)
						},
						{
							"IReference`1",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "Nullable`1", "System.Runtime", false)
						},
						{
							"IVectorView`1",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "IReadOnlyList`1", "System.Runtime", false)
						},
						{
							"IVector`1",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Collections", "System.Collections.Generic", "IList`1", "System.Runtime", false)
						},
						{
							"KeyTime",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "KeyTime", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"Matrix",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Media", "Windows.UI.Xaml.Media", "Matrix", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"Matrix3D",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Media.Media3D", "Windows.UI.Xaml.Media.Media3D", "Matrix3D", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"Matrix3x2",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Matrix3x2", "System.Numerics.Vectors", false)
						},
						{
							"Matrix4x4",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Matrix4x4", "System.Numerics.Vectors", false)
						},
						{
							"NotifyCollectionChangedAction",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedAction", "System.ObjectModel", false)
						},
						{
							"NotifyCollectionChangedEventArgs",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedEventArgs", "System.ObjectModel", false)
						},
						{
							"NotifyCollectionChangedEventHandler",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedEventHandler", "System.ObjectModel", false)
						},
						{
							"Plane",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Plane", "System.Numerics.Vectors", false)
						},
						{
							"Point",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "Windows.Foundation", "Point", "System.Runtime.WindowsRuntime", false)
						},
						{
							"PropertyChangedEventArgs",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Data", "System.ComponentModel", "PropertyChangedEventArgs", "System.ObjectModel", false)
						},
						{
							"PropertyChangedEventHandler",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Data", "System.ComponentModel", "PropertyChangedEventHandler", "System.ObjectModel", false)
						},
						{
							"Quaternion",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Quaternion", "System.Numerics.Vectors", false)
						},
						{
							"Rect",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "Windows.Foundation", "Rect", "System.Runtime.WindowsRuntime", false)
						},
						{
							"RepeatBehavior",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "RepeatBehavior", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"RepeatBehaviorType",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "RepeatBehaviorType", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"Size",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "Windows.Foundation", "Size", "System.Runtime.WindowsRuntime", false)
						},
						{
							"Thickness",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml", "Windows.UI.Xaml", "Thickness", "System.Runtime.WindowsRuntime.UI.Xaml", false)
						},
						{
							"TimeSpan",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "TimeSpan", "System.Runtime", false)
						},
						{
							"TypeName",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.UI.Xaml.Interop", "System", "Type", "System.Runtime", false)
						},
						{
							"Uri",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation", "System", "Uri", "System.Runtime", false)
						},
						{
							"Vector2",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Vector2", "System.Numerics.Vectors", false)
						},
						{
							"Vector3",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Vector3", "System.Numerics.Vectors", false)
						},
						{
							"Vector4",
							new WindowsRuntimeProjections.ProjectionInfo("Windows.Foundation.Numerics", "System.Numerics", "Vector4", "System.Numerics.Vectors", false)
						}
					};
					Interlocked.CompareExchange<Dictionary<string, WindowsRuntimeProjections.ProjectionInfo>>(ref WindowsRuntimeProjections.projections, value, null);
					result = WindowsRuntimeProjections.projections;
				}
				return result;
			}
		}

		// Token: 0x170002B4 RID: 692
		// (get) Token: 0x0600093C RID: 2364 RVA: 0x0002843C File Offset: 0x0002663C
		private AssemblyNameReference[] VirtualReferences
		{
			get
			{
				bool flag = this.virtual_references == null;
				if (flag)
				{
					Mixin.Read(this.module.AssemblyReferences);
				}
				return this.virtual_references;
			}
		}

		// Token: 0x0600093D RID: 2365 RVA: 0x000055C4 File Offset: 0x000037C4
		public WindowsRuntimeProjections(ModuleDefinition module)
		{
			this.module = module;
		}

		// Token: 0x0600093E RID: 2366 RVA: 0x00028474 File Offset: 0x00026674
		public static void Project(TypeDefinition type)
		{
			TypeDefinitionTreatment typeDefinitionTreatment = TypeDefinitionTreatment.None;
			MetadataKind metadataKind = type.Module.MetadataKind;
			Collection<MethodDefinition> redirectedMethods = null;
			Collection<KeyValuePair<InterfaceImplementation, InterfaceImplementation>> redirectedInterfaces = null;
			bool isWindowsRuntime = type.IsWindowsRuntime;
			if (isWindowsRuntime)
			{
				bool flag = metadataKind == MetadataKind.WindowsMetadata;
				if (flag)
				{
					typeDefinitionTreatment = WindowsRuntimeProjections.GetWellKnownTypeDefinitionTreatment(type);
					bool flag2 = typeDefinitionTreatment > TypeDefinitionTreatment.None;
					if (flag2)
					{
						WindowsRuntimeProjections.ApplyProjection(type, new TypeDefinitionProjection(type, typeDefinitionTreatment, redirectedMethods, redirectedInterfaces));
						return;
					}
					TypeReference baseType = type.BaseType;
					bool flag3 = baseType != null && WindowsRuntimeProjections.IsAttribute(baseType);
					if (flag3)
					{
						typeDefinitionTreatment = TypeDefinitionTreatment.NormalAttribute;
					}
					else
					{
						typeDefinitionTreatment = WindowsRuntimeProjections.GenerateRedirectionInformation(type, out redirectedMethods, out redirectedInterfaces);
					}
				}
				else
				{
					bool flag4 = metadataKind == MetadataKind.ManagedWindowsMetadata && WindowsRuntimeProjections.NeedsWindowsRuntimePrefix(type);
					if (flag4)
					{
						typeDefinitionTreatment = TypeDefinitionTreatment.PrefixWindowsRuntimeName;
					}
				}
				bool flag5 = typeDefinitionTreatment == TypeDefinitionTreatment.PrefixWindowsRuntimeName || typeDefinitionTreatment == TypeDefinitionTreatment.NormalType;
				if (flag5)
				{
					bool flag6 = !type.IsInterface && WindowsRuntimeProjections.HasAttribute(type.CustomAttributes, "Windows.UI.Xaml", "TreatAsAbstractComposableClassAttribute");
					if (flag6)
					{
						typeDefinitionTreatment |= TypeDefinitionTreatment.Abstract;
					}
				}
			}
			else
			{
				bool flag7 = metadataKind == MetadataKind.ManagedWindowsMetadata && WindowsRuntimeProjections.IsClrImplementationType(type);
				if (flag7)
				{
					typeDefinitionTreatment = TypeDefinitionTreatment.UnmangleWindowsRuntimeName;
				}
			}
			bool flag8 = typeDefinitionTreatment > TypeDefinitionTreatment.None;
			if (flag8)
			{
				WindowsRuntimeProjections.ApplyProjection(type, new TypeDefinitionProjection(type, typeDefinitionTreatment, redirectedMethods, redirectedInterfaces));
			}
		}

		// Token: 0x0600093F RID: 2367 RVA: 0x0002858C File Offset: 0x0002678C
		private static TypeDefinitionTreatment GetWellKnownTypeDefinitionTreatment(TypeDefinition type)
		{
			WindowsRuntimeProjections.ProjectionInfo projectionInfo;
			bool flag = !WindowsRuntimeProjections.Projections.TryGetValue(type.Name, out projectionInfo);
			TypeDefinitionTreatment result;
			if (flag)
			{
				result = TypeDefinitionTreatment.None;
			}
			else
			{
				TypeDefinitionTreatment typeDefinitionTreatment = projectionInfo.Attribute ? TypeDefinitionTreatment.RedirectToClrAttribute : TypeDefinitionTreatment.RedirectToClrType;
				bool flag2 = type.Namespace == projectionInfo.ClrNamespace;
				if (flag2)
				{
					result = typeDefinitionTreatment;
				}
				else
				{
					bool flag3 = type.Namespace == projectionInfo.WinRTNamespace;
					if (flag3)
					{
						result = (typeDefinitionTreatment | TypeDefinitionTreatment.Internal);
					}
					else
					{
						result = TypeDefinitionTreatment.None;
					}
				}
			}
			return result;
		}

		// Token: 0x06000940 RID: 2368 RVA: 0x00028604 File Offset: 0x00026804
		private static TypeDefinitionTreatment GenerateRedirectionInformation(TypeDefinition type, out Collection<MethodDefinition> redirectedMethods, out Collection<KeyValuePair<InterfaceImplementation, InterfaceImplementation>> redirectedInterfaces)
		{
			bool flag = false;
			redirectedMethods = null;
			redirectedInterfaces = null;
			foreach (InterfaceImplementation interfaceImplementation in type.Interfaces)
			{
				bool flag2 = WindowsRuntimeProjections.IsRedirectedType(interfaceImplementation.InterfaceType);
				if (flag2)
				{
					flag = true;
					break;
				}
			}
			bool flag3 = !flag;
			TypeDefinitionTreatment result;
			if (flag3)
			{
				result = TypeDefinitionTreatment.NormalType;
			}
			else
			{
				HashSet<TypeReference> hashSet = new HashSet<TypeReference>(new TypeReferenceEqualityComparer());
				redirectedMethods = new Collection<MethodDefinition>();
				redirectedInterfaces = new Collection<KeyValuePair<InterfaceImplementation, InterfaceImplementation>>();
				foreach (InterfaceImplementation interfaceImplementation2 in type.Interfaces)
				{
					TypeReference interfaceType = interfaceImplementation2.InterfaceType;
					bool flag4 = WindowsRuntimeProjections.IsRedirectedType(interfaceType);
					if (flag4)
					{
						hashSet.Add(interfaceType);
						WindowsRuntimeProjections.CollectImplementedInterfaces(interfaceType, hashSet);
					}
				}
				foreach (InterfaceImplementation interfaceImplementation3 in type.Interfaces)
				{
					TypeReference interfaceType2 = interfaceImplementation3.InterfaceType;
					bool flag5 = WindowsRuntimeProjections.IsRedirectedType(interfaceImplementation3.InterfaceType);
					if (flag5)
					{
						TypeReference elementType = interfaceType2.GetElementType();
						TypeReference typeReference = new TypeReference(elementType.Namespace, elementType.Name, elementType.Module, elementType.Scope)
						{
							DeclaringType = elementType.DeclaringType,
							projection = elementType.projection
						};
						WindowsRuntimeProjections.RemoveProjection(typeReference);
						GenericInstanceType genericInstanceType = interfaceType2 as GenericInstanceType;
						bool flag6 = genericInstanceType != null;
						if (flag6)
						{
							GenericInstanceType genericInstanceType2 = new GenericInstanceType(typeReference);
							foreach (TypeReference item in genericInstanceType.GenericArguments)
							{
								genericInstanceType2.GenericArguments.Add(item);
							}
							typeReference = genericInstanceType2;
						}
						InterfaceImplementation value = new InterfaceImplementation(typeReference);
						redirectedInterfaces.Add(new KeyValuePair<InterfaceImplementation, InterfaceImplementation>(interfaceImplementation3, value));
					}
				}
				bool flag7 = !type.IsInterface;
				if (flag7)
				{
					foreach (TypeReference interfaceType3 in hashSet)
					{
						WindowsRuntimeProjections.RedirectInterfaceMethods(interfaceType3, redirectedMethods);
					}
				}
				result = TypeDefinitionTreatment.RedirectImplementedMethods;
			}
			return result;
		}

		// Token: 0x06000941 RID: 2369 RVA: 0x000288E8 File Offset: 0x00026AE8
		private static void CollectImplementedInterfaces(TypeReference type, HashSet<TypeReference> results)
		{
			TypeResolver typeResolver = TypeResolver.For(type);
			TypeDefinition typeDefinition = type.Resolve();
			foreach (InterfaceImplementation interfaceImplementation in typeDefinition.Interfaces)
			{
				TypeReference typeReference = typeResolver.Resolve(interfaceImplementation.InterfaceType);
				results.Add(typeReference);
				WindowsRuntimeProjections.CollectImplementedInterfaces(typeReference, results);
			}
		}

		// Token: 0x06000942 RID: 2370 RVA: 0x00028968 File Offset: 0x00026B68
		private static void RedirectInterfaceMethods(TypeReference interfaceType, Collection<MethodDefinition> redirectedMethods)
		{
			TypeResolver typeResolver = TypeResolver.For(interfaceType);
			TypeDefinition typeDefinition = interfaceType.Resolve();
			foreach (MethodDefinition methodDefinition in typeDefinition.Methods)
			{
				MethodDefinition methodDefinition2 = new MethodDefinition(methodDefinition.Name, MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.VtableLayoutMask, typeResolver.Resolve(methodDefinition.ReturnType));
				methodDefinition2.ImplAttributes = MethodImplAttributes.CodeTypeMask;
				foreach (ParameterDefinition parameterDefinition in methodDefinition.Parameters)
				{
					methodDefinition2.Parameters.Add(new ParameterDefinition(parameterDefinition.Name, parameterDefinition.Attributes, typeResolver.Resolve(parameterDefinition.ParameterType)));
				}
				methodDefinition2.Overrides.Add(typeResolver.Resolve(methodDefinition));
				redirectedMethods.Add(methodDefinition2);
			}
		}

		// Token: 0x06000943 RID: 2371 RVA: 0x00028A80 File Offset: 0x00026C80
		private static bool IsRedirectedType(TypeReference type)
		{
			TypeReferenceProjection typeReferenceProjection = type.GetElementType().projection as TypeReferenceProjection;
			return typeReferenceProjection != null && typeReferenceProjection.Treatment == TypeReferenceTreatment.UseProjectionInfo;
		}

		// Token: 0x06000944 RID: 2372 RVA: 0x00028AB4 File Offset: 0x00026CB4
		private static bool NeedsWindowsRuntimePrefix(TypeDefinition type)
		{
			bool flag = (type.Attributes & (TypeAttributes.VisibilityMask | TypeAttributes.ClassSemanticMask)) != TypeAttributes.Public;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				TypeReference baseType = type.BaseType;
				bool flag2 = baseType == null || baseType.MetadataToken.TokenType != TokenType.TypeRef;
				if (flag2)
				{
					result = false;
				}
				else
				{
					bool flag3 = baseType.Namespace == "System";
					if (flag3)
					{
						string name = baseType.Name;
						string a = name;
						if (a == "Attribute" || a == "MulticastDelegate" || a == "ValueType")
						{
							return false;
						}
					}
					result = true;
				}
			}
			return result;
		}

		// Token: 0x06000945 RID: 2373 RVA: 0x00028B64 File Offset: 0x00026D64
		public static bool IsClrImplementationType(TypeDefinition type)
		{
			bool flag = (type.Attributes & (TypeAttributes.VisibilityMask | TypeAttributes.SpecialName)) != TypeAttributes.SpecialName;
			return !flag && type.Name.StartsWith("<CLR>");
		}

		// Token: 0x06000946 RID: 2374 RVA: 0x00028BA4 File Offset: 0x00026DA4
		public static void ApplyProjection(TypeDefinition type, TypeDefinitionProjection projection)
		{
			bool flag = projection == null;
			if (!flag)
			{
				TypeDefinitionTreatment treatment = projection.Treatment;
				switch (treatment & TypeDefinitionTreatment.KindMask)
				{
				case TypeDefinitionTreatment.NormalType:
					type.Attributes |= (TypeAttributes.Import | TypeAttributes.WindowsRuntime);
					break;
				case TypeDefinitionTreatment.NormalAttribute:
					type.Attributes |= (TypeAttributes.Sealed | TypeAttributes.WindowsRuntime);
					break;
				case TypeDefinitionTreatment.UnmangleWindowsRuntimeName:
					type.Attributes = ((type.Attributes & ~TypeAttributes.SpecialName) | TypeAttributes.Public);
					type.Name = type.Name.Substring("<CLR>".Length);
					break;
				case TypeDefinitionTreatment.PrefixWindowsRuntimeName:
					type.Attributes = ((type.Attributes & ~TypeAttributes.Public) | TypeAttributes.Import);
					type.Name = "<WinRT>" + type.Name;
					break;
				case TypeDefinitionTreatment.RedirectToClrType:
					type.Attributes = ((type.Attributes & ~TypeAttributes.Public) | TypeAttributes.Import);
					break;
				case TypeDefinitionTreatment.RedirectToClrAttribute:
					type.Attributes &= ~TypeAttributes.Public;
					break;
				case TypeDefinitionTreatment.RedirectImplementedMethods:
					type.Attributes |= (TypeAttributes.Import | TypeAttributes.WindowsRuntime);
					foreach (KeyValuePair<InterfaceImplementation, InterfaceImplementation> keyValuePair in projection.RedirectedInterfaces)
					{
						type.Interfaces.Add(keyValuePair.Value);
						foreach (CustomAttribute item in keyValuePair.Key.CustomAttributes)
						{
							keyValuePair.Value.CustomAttributes.Add(item);
						}
						keyValuePair.Key.CustomAttributes.Clear();
						foreach (MethodDefinition methodDefinition in type.Methods)
						{
							foreach (MethodReference methodReference in methodDefinition.Overrides)
							{
								bool flag2 = TypeReferenceEqualityComparer.AreEqual(methodReference.DeclaringType, keyValuePair.Key.InterfaceType, TypeComparisonMode.Exact);
								if (flag2)
								{
									methodReference.DeclaringType = keyValuePair.Value.InterfaceType;
								}
							}
						}
					}
					foreach (MethodDefinition item2 in projection.RedirectedMethods)
					{
						type.Methods.Add(item2);
					}
					break;
				}
				bool flag3 = (treatment & TypeDefinitionTreatment.Abstract) > TypeDefinitionTreatment.None;
				if (flag3)
				{
					type.Attributes |= TypeAttributes.Abstract;
				}
				bool flag4 = (treatment & TypeDefinitionTreatment.Internal) > TypeDefinitionTreatment.None;
				if (flag4)
				{
					type.Attributes &= ~TypeAttributes.Public;
				}
				type.WindowsRuntimeProjection = projection;
			}
		}

		// Token: 0x06000947 RID: 2375 RVA: 0x00028F28 File Offset: 0x00027128
		public static TypeDefinitionProjection RemoveProjection(TypeDefinition type)
		{
			bool flag = !type.IsWindowsRuntimeProjection;
			TypeDefinitionProjection result;
			if (flag)
			{
				result = null;
			}
			else
			{
				TypeDefinitionProjection windowsRuntimeProjection = type.WindowsRuntimeProjection;
				type.WindowsRuntimeProjection = null;
				type.Attributes = windowsRuntimeProjection.Attributes;
				type.Name = windowsRuntimeProjection.Name;
				bool flag2 = windowsRuntimeProjection.Treatment == TypeDefinitionTreatment.RedirectImplementedMethods;
				if (flag2)
				{
					foreach (MethodDefinition item in windowsRuntimeProjection.RedirectedMethods)
					{
						type.Methods.Remove(item);
					}
					foreach (KeyValuePair<InterfaceImplementation, InterfaceImplementation> keyValuePair in windowsRuntimeProjection.RedirectedInterfaces)
					{
						foreach (MethodDefinition methodDefinition in type.Methods)
						{
							foreach (MethodReference methodReference in methodDefinition.Overrides)
							{
								bool flag3 = TypeReferenceEqualityComparer.AreEqual(methodReference.DeclaringType, keyValuePair.Value.InterfaceType, TypeComparisonMode.Exact);
								if (flag3)
								{
									methodReference.DeclaringType = keyValuePair.Key.InterfaceType;
								}
							}
						}
						foreach (CustomAttribute item2 in keyValuePair.Value.CustomAttributes)
						{
							keyValuePair.Key.CustomAttributes.Add(item2);
						}
						keyValuePair.Value.CustomAttributes.Clear();
						type.Interfaces.Remove(keyValuePair.Value);
					}
				}
				result = windowsRuntimeProjection;
			}
			return result;
		}

		// Token: 0x06000948 RID: 2376 RVA: 0x00029198 File Offset: 0x00027398
		public static void Project(TypeReference type)
		{
			WindowsRuntimeProjections.ProjectionInfo projectionInfo;
			bool flag = WindowsRuntimeProjections.Projections.TryGetValue(type.Name, out projectionInfo) && projectionInfo.WinRTNamespace == type.Namespace;
			TypeReferenceTreatment typeReferenceTreatment;
			if (flag)
			{
				typeReferenceTreatment = TypeReferenceTreatment.UseProjectionInfo;
			}
			else
			{
				typeReferenceTreatment = WindowsRuntimeProjections.GetSpecialTypeReferenceTreatment(type);
			}
			bool flag2 = typeReferenceTreatment > TypeReferenceTreatment.None;
			if (flag2)
			{
				WindowsRuntimeProjections.ApplyProjection(type, new TypeReferenceProjection(type, typeReferenceTreatment));
			}
		}

		// Token: 0x06000949 RID: 2377 RVA: 0x000291F4 File Offset: 0x000273F4
		private static TypeReferenceTreatment GetSpecialTypeReferenceTreatment(TypeReference type)
		{
			bool flag = type.Namespace == "System";
			if (flag)
			{
				bool flag2 = type.Name == "MulticastDelegate";
				if (flag2)
				{
					return TypeReferenceTreatment.SystemDelegate;
				}
				bool flag3 = type.Name == "Attribute";
				if (flag3)
				{
					return TypeReferenceTreatment.SystemAttribute;
				}
			}
			return TypeReferenceTreatment.None;
		}

		// Token: 0x0600094A RID: 2378 RVA: 0x00029250 File Offset: 0x00027450
		private static bool IsAttribute(TypeReference type)
		{
			bool flag = type.MetadataToken.TokenType != TokenType.TypeRef;
			return !flag && type.Name == "Attribute" && type.Namespace == "System";
		}

		// Token: 0x0600094B RID: 2379 RVA: 0x000292A8 File Offset: 0x000274A8
		private static bool IsEnum(TypeReference type)
		{
			bool flag = type.MetadataToken.TokenType != TokenType.TypeRef;
			return !flag && type.Name == "Enum" && type.Namespace == "System";
		}

		// Token: 0x0600094C RID: 2380 RVA: 0x00029300 File Offset: 0x00027500
		public static void ApplyProjection(TypeReference type, TypeReferenceProjection projection)
		{
			bool flag = projection == null;
			if (!flag)
			{
				TypeReferenceTreatment treatment = projection.Treatment;
				TypeReferenceTreatment typeReferenceTreatment = treatment;
				if (typeReferenceTreatment - TypeReferenceTreatment.SystemDelegate > 1)
				{
					if (typeReferenceTreatment == TypeReferenceTreatment.UseProjectionInfo)
					{
						WindowsRuntimeProjections.ProjectionInfo projectionInfo = WindowsRuntimeProjections.Projections[type.Name];
						type.Name = projectionInfo.ClrName;
						type.Namespace = projectionInfo.ClrNamespace;
						type.Scope = type.Module.Projections.GetAssemblyReference(projectionInfo.ClrAssembly);
					}
				}
				else
				{
					type.Scope = type.Module.Projections.GetAssemblyReference("System.Runtime");
				}
				type.WindowsRuntimeProjection = projection;
			}
		}

		// Token: 0x0600094D RID: 2381 RVA: 0x000293A4 File Offset: 0x000275A4
		public static TypeReferenceProjection RemoveProjection(TypeReference type)
		{
			bool flag = !type.IsWindowsRuntimeProjection;
			TypeReferenceProjection result;
			if (flag)
			{
				result = null;
			}
			else
			{
				TypeReferenceProjection windowsRuntimeProjection = type.WindowsRuntimeProjection;
				type.WindowsRuntimeProjection = null;
				type.Name = windowsRuntimeProjection.Name;
				type.Namespace = windowsRuntimeProjection.Namespace;
				type.Scope = windowsRuntimeProjection.Scope;
				result = windowsRuntimeProjection;
			}
			return result;
		}

		// Token: 0x0600094E RID: 2382 RVA: 0x00029400 File Offset: 0x00027600
		public static void Project(MethodDefinition method)
		{
			MethodDefinitionTreatment methodDefinitionTreatment = MethodDefinitionTreatment.None;
			bool flag = false;
			TypeDefinition declaringType = method.DeclaringType;
			bool isWindowsRuntime = declaringType.IsWindowsRuntime;
			if (isWindowsRuntime)
			{
				bool flag2 = WindowsRuntimeProjections.IsClrImplementationType(declaringType);
				if (flag2)
				{
					methodDefinitionTreatment = MethodDefinitionTreatment.None;
				}
				else
				{
					bool isNested = declaringType.IsNested;
					if (isNested)
					{
						methodDefinitionTreatment = MethodDefinitionTreatment.None;
					}
					else
					{
						bool isInterface = declaringType.IsInterface;
						if (isInterface)
						{
							methodDefinitionTreatment = (MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall);
						}
						else
						{
							bool flag3 = declaringType.Module.MetadataKind == MetadataKind.ManagedWindowsMetadata && !method.IsPublic;
							if (flag3)
							{
								methodDefinitionTreatment = MethodDefinitionTreatment.None;
							}
							else
							{
								flag = true;
								TypeReference baseType = declaringType.BaseType;
								bool flag4 = baseType != null && baseType.MetadataToken.TokenType == TokenType.TypeRef;
								if (flag4)
								{
									TypeReferenceTreatment specialTypeReferenceTreatment = WindowsRuntimeProjections.GetSpecialTypeReferenceTreatment(baseType);
									TypeReferenceTreatment typeReferenceTreatment = specialTypeReferenceTreatment;
									if (typeReferenceTreatment != TypeReferenceTreatment.SystemDelegate)
									{
										if (typeReferenceTreatment == TypeReferenceTreatment.SystemAttribute)
										{
											methodDefinitionTreatment = (MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall);
											flag = false;
										}
									}
									else
									{
										methodDefinitionTreatment = (MethodDefinitionTreatment.Public | MethodDefinitionTreatment.Runtime);
										flag = false;
									}
								}
							}
						}
					}
				}
			}
			bool flag5 = flag;
			if (flag5)
			{
				bool flag6 = false;
				bool flag7 = false;
				foreach (MethodReference methodReference in method.Overrides)
				{
					bool flag8 = methodReference.MetadataToken.TokenType == TokenType.MemberRef && WindowsRuntimeProjections.ImplementsRedirectedInterface(methodReference);
					if (flag8)
					{
						flag6 = true;
					}
					else
					{
						flag7 = true;
					}
				}
				bool flag9 = flag6 && !flag7;
				if (flag9)
				{
					methodDefinitionTreatment = (MethodDefinitionTreatment.Private | MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall);
					flag = false;
				}
			}
			bool flag10 = flag;
			if (flag10)
			{
				methodDefinitionTreatment |= WindowsRuntimeProjections.GetMethodDefinitionTreatmentFromCustomAttributes(method);
			}
			bool flag11 = methodDefinitionTreatment > MethodDefinitionTreatment.None;
			if (flag11)
			{
				WindowsRuntimeProjections.ApplyProjection(method, new MethodDefinitionProjection(method, methodDefinitionTreatment));
			}
		}

		// Token: 0x0600094F RID: 2383 RVA: 0x000295AC File Offset: 0x000277AC
		private static MethodDefinitionTreatment GetMethodDefinitionTreatmentFromCustomAttributes(MethodDefinition method)
		{
			MethodDefinitionTreatment methodDefinitionTreatment = MethodDefinitionTreatment.None;
			foreach (CustomAttribute customAttribute in method.CustomAttributes)
			{
				TypeReference attributeType = customAttribute.AttributeType;
				bool flag = attributeType.Namespace != "Windows.UI.Xaml";
				if (!flag)
				{
					bool flag2 = attributeType.Name == "TreatAsPublicMethodAttribute";
					if (flag2)
					{
						methodDefinitionTreatment |= MethodDefinitionTreatment.Public;
					}
					else
					{
						bool flag3 = attributeType.Name == "TreatAsAbstractMethodAttribute";
						if (flag3)
						{
							methodDefinitionTreatment |= MethodDefinitionTreatment.Abstract;
						}
					}
				}
			}
			return methodDefinitionTreatment;
		}

		// Token: 0x06000950 RID: 2384 RVA: 0x0002965C File Offset: 0x0002785C
		public static void ApplyProjection(MethodDefinition method, MethodDefinitionProjection projection)
		{
			bool flag = projection == null;
			if (!flag)
			{
				MethodDefinitionTreatment treatment = projection.Treatment;
				bool flag2 = (treatment & MethodDefinitionTreatment.Abstract) > MethodDefinitionTreatment.None;
				if (flag2)
				{
					method.Attributes |= MethodAttributes.Abstract;
				}
				bool flag3 = (treatment & MethodDefinitionTreatment.Private) > MethodDefinitionTreatment.None;
				if (flag3)
				{
					method.Attributes = ((method.Attributes & ~MethodAttributes.MemberAccessMask) | MethodAttributes.Private);
				}
				bool flag4 = (treatment & MethodDefinitionTreatment.Public) > MethodDefinitionTreatment.None;
				if (flag4)
				{
					method.Attributes = ((method.Attributes & ~MethodAttributes.MemberAccessMask) | MethodAttributes.Public);
				}
				bool flag5 = (treatment & MethodDefinitionTreatment.Runtime) > MethodDefinitionTreatment.None;
				if (flag5)
				{
					method.ImplAttributes |= MethodImplAttributes.CodeTypeMask;
				}
				bool flag6 = (treatment & MethodDefinitionTreatment.InternalCall) > MethodDefinitionTreatment.None;
				if (flag6)
				{
					method.ImplAttributes |= MethodImplAttributes.InternalCall;
				}
				method.WindowsRuntimeProjection = projection;
			}
		}

		// Token: 0x06000951 RID: 2385 RVA: 0x00029720 File Offset: 0x00027920
		public static MethodDefinitionProjection RemoveProjection(MethodDefinition method)
		{
			bool flag = !method.IsWindowsRuntimeProjection;
			MethodDefinitionProjection result;
			if (flag)
			{
				result = null;
			}
			else
			{
				MethodDefinitionProjection windowsRuntimeProjection = method.WindowsRuntimeProjection;
				method.WindowsRuntimeProjection = null;
				method.Attributes = windowsRuntimeProjection.Attributes;
				method.ImplAttributes = windowsRuntimeProjection.ImplAttributes;
				method.Name = windowsRuntimeProjection.Name;
				result = windowsRuntimeProjection;
			}
			return result;
		}

		// Token: 0x06000952 RID: 2386 RVA: 0x0002977C File Offset: 0x0002797C
		public static void Project(FieldDefinition field)
		{
			FieldDefinitionTreatment fieldDefinitionTreatment = FieldDefinitionTreatment.None;
			TypeDefinition declaringType = field.DeclaringType;
			bool flag = declaringType.Module.MetadataKind == MetadataKind.WindowsMetadata && field.IsRuntimeSpecialName && field.Name == "value__";
			if (flag)
			{
				TypeReference baseType = declaringType.BaseType;
				bool flag2 = baseType != null && WindowsRuntimeProjections.IsEnum(baseType);
				if (flag2)
				{
					fieldDefinitionTreatment = FieldDefinitionTreatment.Public;
				}
			}
			bool flag3 = fieldDefinitionTreatment > FieldDefinitionTreatment.None;
			if (flag3)
			{
				WindowsRuntimeProjections.ApplyProjection(field, new FieldDefinitionProjection(field, fieldDefinitionTreatment));
			}
		}

		// Token: 0x06000953 RID: 2387 RVA: 0x000297F8 File Offset: 0x000279F8
		public static void ApplyProjection(FieldDefinition field, FieldDefinitionProjection projection)
		{
			bool flag = projection == null;
			if (!flag)
			{
				bool flag2 = projection.Treatment == FieldDefinitionTreatment.Public;
				if (flag2)
				{
					field.Attributes = ((field.Attributes & ~FieldAttributes.FieldAccessMask) | FieldAttributes.Public);
				}
				field.WindowsRuntimeProjection = projection;
			}
		}

		// Token: 0x06000954 RID: 2388 RVA: 0x0002983C File Offset: 0x00027A3C
		public static FieldDefinitionProjection RemoveProjection(FieldDefinition field)
		{
			bool flag = !field.IsWindowsRuntimeProjection;
			FieldDefinitionProjection result;
			if (flag)
			{
				result = null;
			}
			else
			{
				FieldDefinitionProjection windowsRuntimeProjection = field.WindowsRuntimeProjection;
				field.WindowsRuntimeProjection = null;
				field.Attributes = windowsRuntimeProjection.Attributes;
				result = windowsRuntimeProjection;
			}
			return result;
		}

		// Token: 0x06000955 RID: 2389 RVA: 0x0002987C File Offset: 0x00027A7C
		private static bool ImplementsRedirectedInterface(MemberReference member)
		{
			TypeReference declaringType = member.DeclaringType;
			TokenType tokenType = declaringType.MetadataToken.TokenType;
			TokenType tokenType2 = tokenType;
			TypeReference typeReference;
			if (tokenType2 != TokenType.TypeRef)
			{
				if (tokenType2 != TokenType.TypeSpec)
				{
					return false;
				}
				bool flag = !declaringType.IsGenericInstance;
				if (flag)
				{
					return false;
				}
				typeReference = ((TypeSpecification)declaringType).ElementType;
				bool flag2 = typeReference.MetadataType != MetadataType.Class || typeReference.MetadataToken.TokenType != TokenType.TypeRef;
				if (flag2)
				{
					return false;
				}
			}
			else
			{
				typeReference = declaringType;
			}
			TypeReferenceProjection projection = WindowsRuntimeProjections.RemoveProjection(typeReference);
			bool result = false;
			WindowsRuntimeProjections.ProjectionInfo projectionInfo;
			bool flag3 = WindowsRuntimeProjections.Projections.TryGetValue(typeReference.Name, out projectionInfo) && typeReference.Namespace == projectionInfo.WinRTNamespace;
			if (flag3)
			{
				result = true;
			}
			WindowsRuntimeProjections.ApplyProjection(typeReference, projection);
			return result;
		}

		// Token: 0x06000956 RID: 2390 RVA: 0x00029968 File Offset: 0x00027B68
		public void AddVirtualReferences(Collection<AssemblyNameReference> references)
		{
			AssemblyNameReference coreLibrary = WindowsRuntimeProjections.GetCoreLibrary(references);
			this.corlib_version = coreLibrary.Version;
			coreLibrary.Version = WindowsRuntimeProjections.version;
			bool flag = this.virtual_references == null;
			if (flag)
			{
				AssemblyNameReference[] assemblyReferences = WindowsRuntimeProjections.GetAssemblyReferences(coreLibrary);
				Interlocked.CompareExchange<AssemblyNameReference[]>(ref this.virtual_references, assemblyReferences, null);
			}
			foreach (AssemblyNameReference item in this.virtual_references)
			{
				references.Add(item);
			}
		}

		// Token: 0x06000957 RID: 2391 RVA: 0x000299E4 File Offset: 0x00027BE4
		public void RemoveVirtualReferences(Collection<AssemblyNameReference> references)
		{
			AssemblyNameReference coreLibrary = WindowsRuntimeProjections.GetCoreLibrary(references);
			coreLibrary.Version = this.corlib_version;
			foreach (AssemblyNameReference item in this.VirtualReferences)
			{
				references.Remove(item);
			}
		}

		// Token: 0x06000958 RID: 2392 RVA: 0x00029A28 File Offset: 0x00027C28
		private static AssemblyNameReference[] GetAssemblyReferences(AssemblyNameReference corlib)
		{
			AssemblyNameReference assemblyNameReference = new AssemblyNameReference("System.Runtime", WindowsRuntimeProjections.version);
			AssemblyNameReference assemblyNameReference2 = new AssemblyNameReference("System.Runtime.InteropServices.WindowsRuntime", WindowsRuntimeProjections.version);
			AssemblyNameReference assemblyNameReference3 = new AssemblyNameReference("System.ObjectModel", WindowsRuntimeProjections.version);
			AssemblyNameReference assemblyNameReference4 = new AssemblyNameReference("System.Runtime.WindowsRuntime", WindowsRuntimeProjections.version);
			AssemblyNameReference assemblyNameReference5 = new AssemblyNameReference("System.Runtime.WindowsRuntime.UI.Xaml", WindowsRuntimeProjections.version);
			AssemblyNameReference assemblyNameReference6 = new AssemblyNameReference("System.Numerics.Vectors", WindowsRuntimeProjections.version);
			bool hasPublicKey = corlib.HasPublicKey;
			if (hasPublicKey)
			{
				assemblyNameReference4.PublicKey = (assemblyNameReference5.PublicKey = corlib.PublicKey);
				assemblyNameReference.PublicKey = (assemblyNameReference2.PublicKey = (assemblyNameReference3.PublicKey = (assemblyNameReference6.PublicKey = WindowsRuntimeProjections.contract_pk)));
			}
			else
			{
				assemblyNameReference4.PublicKeyToken = (assemblyNameReference5.PublicKeyToken = corlib.PublicKeyToken);
				assemblyNameReference.PublicKeyToken = (assemblyNameReference2.PublicKeyToken = (assemblyNameReference3.PublicKeyToken = (assemblyNameReference6.PublicKeyToken = WindowsRuntimeProjections.contract_pk_token)));
			}
			return new AssemblyNameReference[]
			{
				assemblyNameReference,
				assemblyNameReference2,
				assemblyNameReference3,
				assemblyNameReference4,
				assemblyNameReference5,
				assemblyNameReference6
			};
		}

		// Token: 0x06000959 RID: 2393 RVA: 0x00029B68 File Offset: 0x00027D68
		private static AssemblyNameReference GetCoreLibrary(Collection<AssemblyNameReference> references)
		{
			foreach (AssemblyNameReference assemblyNameReference in references)
			{
				bool flag = assemblyNameReference.Name == "mscorlib";
				if (flag)
				{
					return assemblyNameReference;
				}
			}
			throw new BadImageFormatException("Missing mscorlib reference in AssemblyRef table.");
		}

		// Token: 0x0600095A RID: 2394 RVA: 0x00029BD8 File Offset: 0x00027DD8
		private AssemblyNameReference GetAssemblyReference(string name)
		{
			foreach (AssemblyNameReference assemblyNameReference in this.VirtualReferences)
			{
				bool flag = assemblyNameReference.Name == name;
				if (flag)
				{
					return assemblyNameReference;
				}
			}
			throw new Exception();
		}

		// Token: 0x0600095B RID: 2395 RVA: 0x00029C20 File Offset: 0x00027E20
		public static void Project(ICustomAttributeProvider owner, Collection<CustomAttribute> owner_attributes, CustomAttribute attribute)
		{
			bool flag = !WindowsRuntimeProjections.IsWindowsAttributeUsageAttribute(owner, attribute);
			if (!flag)
			{
				CustomAttributeValueTreatment customAttributeValueTreatment = CustomAttributeValueTreatment.None;
				TypeDefinition typeDefinition = (TypeDefinition)owner;
				bool flag2 = typeDefinition.Namespace == "Windows.Foundation.Metadata";
				if (flag2)
				{
					bool flag3 = typeDefinition.Name == "VersionAttribute";
					if (flag3)
					{
						customAttributeValueTreatment = CustomAttributeValueTreatment.VersionAttribute;
					}
					else
					{
						bool flag4 = typeDefinition.Name == "DeprecatedAttribute";
						if (flag4)
						{
							customAttributeValueTreatment = CustomAttributeValueTreatment.DeprecatedAttribute;
						}
					}
				}
				bool flag5 = customAttributeValueTreatment == CustomAttributeValueTreatment.None;
				if (flag5)
				{
					customAttributeValueTreatment = (WindowsRuntimeProjections.HasAttribute(owner_attributes, "Windows.Foundation.Metadata", "AllowMultipleAttribute") ? CustomAttributeValueTreatment.AllowMultiple : CustomAttributeValueTreatment.AllowSingle);
				}
				bool flag6 = customAttributeValueTreatment > CustomAttributeValueTreatment.None;
				if (flag6)
				{
					AttributeTargets targets = (AttributeTargets)attribute.ConstructorArguments[0].Value;
					WindowsRuntimeProjections.ApplyProjection(attribute, new CustomAttributeValueProjection(targets, customAttributeValueTreatment));
				}
			}
		}

		// Token: 0x0600095C RID: 2396 RVA: 0x00029CF0 File Offset: 0x00027EF0
		private static bool IsWindowsAttributeUsageAttribute(ICustomAttributeProvider owner, CustomAttribute attribute)
		{
			bool flag = owner.MetadataToken.TokenType != TokenType.TypeDef;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				MethodReference constructor = attribute.Constructor;
				bool flag2 = constructor.MetadataToken.TokenType != TokenType.MemberRef;
				if (flag2)
				{
					result = false;
				}
				else
				{
					TypeReference declaringType = constructor.DeclaringType;
					bool flag3 = declaringType.MetadataToken.TokenType != TokenType.TypeRef;
					result = (!flag3 && declaringType.Name == "AttributeUsageAttribute" && declaringType.Namespace == "System");
				}
			}
			return result;
		}

		// Token: 0x0600095D RID: 2397 RVA: 0x00029DA0 File Offset: 0x00027FA0
		private static bool HasAttribute(Collection<CustomAttribute> attributes, string @namespace, string name)
		{
			foreach (CustomAttribute customAttribute in attributes)
			{
				TypeReference attributeType = customAttribute.AttributeType;
				bool flag = attributeType.Name == name && attributeType.Namespace == @namespace;
				if (flag)
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x0600095E RID: 2398 RVA: 0x00029E20 File Offset: 0x00028020
		public static void ApplyProjection(CustomAttribute attribute, CustomAttributeValueProjection projection)
		{
			bool flag = projection == null;
			if (!flag)
			{
				bool flag2;
				bool flag3;
				switch (projection.Treatment)
				{
				case CustomAttributeValueTreatment.AllowSingle:
					flag2 = false;
					flag3 = false;
					break;
				case CustomAttributeValueTreatment.AllowMultiple:
					flag2 = false;
					flag3 = true;
					break;
				case CustomAttributeValueTreatment.VersionAttribute:
				case CustomAttributeValueTreatment.DeprecatedAttribute:
					flag2 = true;
					flag3 = true;
					break;
				default:
					throw new ArgumentException();
				}
				AttributeTargets attributeTargets = (AttributeTargets)attribute.ConstructorArguments[0].Value;
				bool flag4 = flag2;
				if (flag4)
				{
					attributeTargets |= (AttributeTargets.Constructor | AttributeTargets.Property);
				}
				attribute.ConstructorArguments[0] = new CustomAttributeArgument(attribute.ConstructorArguments[0].Type, attributeTargets);
				attribute.Properties.Add(new CustomAttributeNamedArgument("AllowMultiple", new CustomAttributeArgument(attribute.Module.TypeSystem.Boolean, flag3)));
				attribute.projection = projection;
			}
		}

		// Token: 0x0600095F RID: 2399 RVA: 0x00029F0C File Offset: 0x0002810C
		public static CustomAttributeValueProjection RemoveProjection(CustomAttribute attribute)
		{
			bool flag = attribute.projection == null;
			CustomAttributeValueProjection result;
			if (flag)
			{
				result = null;
			}
			else
			{
				CustomAttributeValueProjection projection = attribute.projection;
				attribute.projection = null;
				attribute.ConstructorArguments[0] = new CustomAttributeArgument(attribute.ConstructorArguments[0].Type, projection.Targets);
				attribute.Properties.Clear();
				result = projection;
			}
			return result;
		}

		// Token: 0x040003B7 RID: 951
		private static readonly Version version = new Version(4, 0, 0, 0);

		// Token: 0x040003B8 RID: 952
		private static readonly byte[] contract_pk_token = new byte[]
		{
			176,
			63,
			95,
			127,
			17,
			213,
			10,
			58
		};

		// Token: 0x040003B9 RID: 953
		private static readonly byte[] contract_pk = new byte[]
		{
			0,
			36,
			0,
			0,
			4,
			128,
			0,
			0,
			148,
			0,
			0,
			0,
			6,
			2,
			0,
			0,
			0,
			36,
			0,
			0,
			82,
			83,
			65,
			49,
			0,
			4,
			0,
			0,
			1,
			0,
			1,
			0,
			7,
			209,
			250,
			87,
			196,
			174,
			217,
			240,
			163,
			46,
			132,
			170,
			15,
			174,
			253,
			13,
			233,
			232,
			253,
			106,
			236,
			143,
			135,
			251,
			3,
			118,
			108,
			131,
			76,
			153,
			146,
			30,
			178,
			59,
			231,
			154,
			217,
			213,
			220,
			193,
			221,
			154,
			210,
			54,
			19,
			33,
			2,
			144,
			11,
			114,
			60,
			249,
			128,
			149,
			127,
			196,
			225,
			119,
			16,
			143,
			198,
			7,
			119,
			79,
			41,
			232,
			50,
			14,
			146,
			234,
			5,
			236,
			228,
			232,
			33,
			192,
			165,
			239,
			232,
			241,
			100,
			92,
			76,
			12,
			147,
			193,
			171,
			153,
			40,
			93,
			98,
			44,
			170,
			101,
			44,
			29,
			250,
			214,
			61,
			116,
			93,
			111,
			45,
			229,
			241,
			126,
			94,
			175,
			15,
			196,
			150,
			61,
			38,
			28,
			138,
			18,
			67,
			101,
			24,
			32,
			109,
			192,
			147,
			52,
			77,
			90,
			210,
			147
		};

		// Token: 0x040003BA RID: 954
		private static Dictionary<string, WindowsRuntimeProjections.ProjectionInfo> projections;

		// Token: 0x040003BB RID: 955
		private readonly ModuleDefinition module;

		// Token: 0x040003BC RID: 956
		private Version corlib_version = new Version(255, 255, 255, 255);

		// Token: 0x040003BD RID: 957
		private AssemblyNameReference[] virtual_references;

		// Token: 0x020000E9 RID: 233
		private struct ProjectionInfo
		{
			// Token: 0x06000961 RID: 2401 RVA: 0x00005634 File Offset: 0x00003834
			public ProjectionInfo(string winrt_namespace, string clr_namespace, string clr_name, string clr_assembly, bool attribute = false)
			{
				this.WinRTNamespace = winrt_namespace;
				this.ClrNamespace = clr_namespace;
				this.ClrName = clr_name;
				this.ClrAssembly = clr_assembly;
				this.Attribute = attribute;
			}

			// Token: 0x040003BE RID: 958
			public readonly string WinRTNamespace;

			// Token: 0x040003BF RID: 959
			public readonly string ClrNamespace;

			// Token: 0x040003C0 RID: 960
			public readonly string ClrName;

			// Token: 0x040003C1 RID: 961
			public readonly string ClrAssembly;

			// Token: 0x040003C2 RID: 962
			public readonly bool Attribute;
		}
	}
}
